package es.wtestgen.util;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;

public class ExcepcionHandler extends ExceptionHandler    
{   
        public ActionForward execute(Exception exception, ExceptionConfig config,                      
               ActionMapping mapping, ActionForm form, HttpServletRequest request,    
               HttpServletResponse response) throws ServletException    
        {   
                if(exception.getClass().equals(NombreUsuaException.class))   
                {   
                	return mapping.findForward("errorNombreUsua");   
                }else if(exception.getClass().equals(DniDuplicadoException.class))
                {
                	return mapping.findForward("errorDniDuplicado");                	
                }
                else   
                {   
                        request.setAttribute("exception",exception);   
                        return mapping.findForward("error");   
                }   
        }   
}
